{% extends "default/admin/include/innerBase.html" %}{% block mainer %}{% load filters %}
路径:/{% for e in path.path|pathList %}<a href="/listImage/{{path.dir}}{{e.path}}.html">{{e.name}}</a>/{%endfor%}
<table border=1>
  <tr>
    <th width="100px">类型</th>
    <th width="100px">内容</th>
    <th width="100px">操作</th>
  </tr>
{% for e in imglist %}
  <tr id="e-{{forloop.counter}}">{%if e.type == 'dir' %}
	<td>目录</td>
    <td><a href="/listImage/{{path.dir}}{{path.path}}/{{e.name}}.html">{{e.name}}</a></td>
    <td><a href="javascript:delImage('rmdir' ,'{{e.name}}',{{forloop.counter}});">删除</a></td>{%endif%}{%if e.type == 'img' %}<td>图片</td>
    <td><img style="width:200px;" src="/media/{{path.dir}}{{path.path}}/{{e.name}}" /></td>
    <td><a href="javascript:delImage('delete' ,'{{e.name}}',{{forloop.counter}});">删除</a></td>{%endif%}
  </tr>{%endfor%}
</table>
<form><div>目录名：<input type="text" id="dir" name="dir"><input type="button" value="创建" onClick="mkdir();"></div></form>
{% include site.theme|stringformat:"s/include/pager.html" with pager=pager %}
<script>
function delImage(action, name, id){
	$("#e-"+id).attr('bgcolor','red');
	$.dialog.confirm('确定要删除此项么?',
			function(){
				var url="/"+action+"Image/{{path.dir}}.do";
				$.post(url, {_retType:"json", path:"{{path.path}}", name:name}, function(data){
							if(data.flag){$("#e-"+id).attr('bgcolor','red').fadeOut("slow",function(){$(this).remove();});}
							else $.dialog.alert(data.msg, function(){$("#e-"+id).removeAttr('bgcolor');});
				},'json');
			},
			function(){$("#e-"+id).removeAttr('bgcolor');}
	);
}
function mkdir(){
	path = $("#dir").val();
	if(path==""){$.dialog.alert("目录名不能为空！");return false;}
	var url="/mkdirImage/{{path.dir}}/"+path+".do";
	$.post(url, {_retType:"json"}, function(data){$.dialog.alert(data.msg);},'json');
}
</script>
{% endblock %}